//
//  AppendFishpondHeaderView.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/7/22.
//

#import "AppendFishpondHeaderView.h"
#import "YTBaseSelectStringView.h"
#import "YTBaseEditorStringView.h"


@interface AppendFishpondHeaderView ()
///池塘类型
@property (nonatomic ,strong)  YTBaseSelectStringView * typeName;
@property (nonatomic ,strong)  YTBaseEditorStringView * name;

@property (nonatomic ,strong)  YTBaseSelectStringView * tissueName;

@end
@implementation AppendFishpondHeaderView

+ (instancetype)NewView{
    AppendFishpondHeaderView * view = [AppendFishpondHeaderView new];
    view.backgroundColor = UIColor.whiteColor;
    [view setupView];
    return view;
}

- (void)setupView{
    UIView * oneview = [UIView new];
    oneview.backgroundColor = KcolorHex(@"#F0F0F0");
    [DTKTool YJ:kwt(5) andView:oneview];
    [self addSubview:oneview];
    [oneview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(10));
        make.right.offset(kwt(-10));
        make.top.offset(kwt(10));
        make.height.offset(kwt(50));
    }];
    
    UILabel * onelab = [DTKTool labelWithText:@"新增池塘数量" andFont:kCFont(17) andTextColor:KcolorHex(@"#888888")];
    [oneview addSubview:onelab];
    [onelab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(10));
        make.centerY.offset(0);
    }];
    UILabel * onerightlab = [DTKTool labelWithText:@"1个" andFont:kCFont(17) andTextColor:KcolorHex(@"#888888")];
    [oneview addSubview:onerightlab];
    [onerightlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-10));
        make.centerY.offset(0);
    }];
    MJWeakSelf
    YTBaseSelectStringView * typeName = [YTBaseSelectStringView NewView];
    self.typeName = typeName;
    typeName.forceFlag = YES;
    typeName.name = @"池塘类型";
    typeName.block = ^(NSString * _Nonnull content) {
        if(weakSelf.openTKLXBlock){
            weakSelf.openTKLXBlock(weakSelf.model);
        }
    };
    [self addSubview:typeName];
    [typeName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-10));
        make.left.offset(kwt(10));
        make.top.equalTo(oneview.mas_bottom).offset(kwt(5));
        make.height.offset(kwt(60));
    }];
    
    YTBaseEditorStringView * name = [YTBaseEditorStringView NewView];
    self.name = name;
    name.forceFlag = YES;
    name.name = @"池塘名称";
    name.placeholder = @"请填写池塘名称";
    name.block = ^(NSString * _Nonnull content) {
        weakSelf.model.addPondModelList.firstObject.name = content;
    };
    [self addSubview:name];
    [name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-10));
        make.left.offset(kwt(10));
        make.top.equalTo(typeName.mas_bottom);
        make.height.offset(kwt(60));

    }];
    
    YTBaseSelectStringView * tissueName = [YTBaseSelectStringView NewView];
    self.tissueName = tissueName;
    tissueName.forceFlag = YES;
    tissueName.name = @"池塘编组";
    [self addSubview:tissueName];
    [tissueName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-10));
        make.left.offset(kwt(10));
        make.top.equalTo(name.mas_bottom);
        make.height.offset(kwt(60));

    }];
    tissueName.block = ^(NSString * _Nonnull content) {
        if(weakSelf.openTKBZBlock){
            weakSelf.openTKBZBlock(weakSelf.model.addPondModelList.firstObject);
        }
    };
}


-(void)setModel:(AddPondModel *)model {
    _model = model;
    self.typeName.content = model.typeName;
    self.name.content = model.addPondModelList.firstObject.name;
    self.tissueName.content = model.addPondModelList.firstObject.tissueName;

}

@end
